package itsos.service.impl;

import java.sql.*;
import javax.servlet.http.*;

import org.springframework.web.servlet.ModelAndView;

import itsos.dao.*;
import itsos.model.*;
import itsos.service.*;

public class LoginServiceImpl implements LoginService {

	private MemberDao memberDao;
	
	public void setMemberDao(MemberDao memberDao)
	{
		this.memberDao = memberDao;
	}
	
	
	public boolean doLogin(HttpServletRequest request)
	{
		
		Member member = new Member();
		HttpSession session = request.getSession();
		String pass;
		
		member.setLoginID(request.getParameter("loginID"));
		member.setPassword(request.getParameter("password"));
		pass = member.getPassword();
		
		member = memberDao.doLogin(member.getLoginID());
		
		if(member!=null)
		{
		
		if(member.getPassword()==null)
		{
			return false;
		}
		else if(!(member.getPassword().equals(pass)))
		{
			return false;
		}
		
		session.setAttribute("memberID", member.getMemberID());
		session.setAttribute("loginID", member.getLoginID());
		session.setAttribute("memberGroup", member.getMemberGroup());
		
		return true;
		}
		return false;
	}

	
	
	
	
}
